﻿using System.Threading.Tasks;
using SignalR.Hubs;

namespace TinyContactManager.Web.Internal.Signaling
{
    [HubName("contactHub")]
    public class ContactHub : Hub, IDisconnect
    {
        private readonly ContactNotification _contacts;

        public ContactHub(ContactNotification contacts)
        {
            _contacts = contacts;
        }

        public ContactHub()
            : this(ContactNotification.Instance)
        {
        }

        public Task Disconnect()
        {
            var tcs = new TaskCompletionSource<object>();
            tcs.SetResult(null);
            return tcs.Task;
        }

        public void Login(string group)
        {
            Groups.Add(Context.ConnectionId, group);
        }
    }
}